//在窗口上绘制一条红色的字符串，一个绿色的矩形框和一个蓝色的椭圆块
import javax.swing.*;
import java.awt.*;
class PaintPanel extends JPanel{
    public void paintComponent(Graphics g){
        super.paintComponent(g);

        g.setColor(Color.red);
        g.setFont(new Font("黑体",Font.BOLD,40));
        g.drawString("湖工欢迎你！",50,100);

        g.setColor(Color.green);
        g.drawRect(50,200,300,200);

        g.setColor(Color.blue);
        g.fillOval(50,200,300,200);
    }
}
public class MyFrame extends JFrame {
    MyFrame(String s){
        super(s);
        setBounds(200,250,1000,1000);

        PaintPanel paintPanel=new PaintPanel();
        add(paintPanel);

        setVisible(true);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
    public static void main(String[] args) {
        new MyFrame("绘制图形");
    }
}
